package com.sgfm.util;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class Base64Utils {

	public static String encodeBase64(String str) {
		String result = null;
		BASE64Encoder encoder = new BASE64Encoder();
		try {
			result = encoder.encode(str.getBytes("utf-8"));
		} catch (UnsupportedEncodingException e) {

		}
		return result;
	}

	public static String decodeBase64(String str) {
		String result = null;
		BASE64Decoder decoder = new BASE64Decoder();
		try {
			result = new String(decoder.decodeBuffer(str), "utf-8");
		} catch (IOException e) {

		}
		return result;
	}

}
